export function formatImageUrl(url) {
  if (/^[/\\]?profile\/upload/.test(url)) {
    url =
      window.shuchao_config.imageURL.replace(/[/\\]+$/g, "") +
      "/" +
      url.replace(/^[/\\]+/g, "");
  }
  return url;
}

export function dealHtmlImg(html) {
  if (typeof html !== "string") {
    return html;
  }

  return html.replace(/src="([^"]+)"/gi, (result, $1) => {
    return `src="${formatImageUrl($1)}"`;
  });
}
